/**
 * 
 */
package com.gopay.common.cps.dao.bt.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.bt.CpsBtContractLogQueryDAO;
import com.gopay.common.domain.cps.CpsBtContractLog;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * 大宗合约签约解约日志表
 * 
 * @CpsBtContractLogQueryDAOImpl.java
 * @author xiefei
 * @2013-1-22 上午11:34:59 www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("cpsBtContractLogQueryDAO")
public class CpsBtContractLogQueryDAOImpl extends BaseDAOImpl<CpsBtContractLog, Serializable> implements
        CpsBtContractLogQueryDAO {

    /**
     * 获取合约日志
     * 
     * @param contractId
     * @param inTxnCD
     * @return
     */
    @Override
    public CpsBtContractLog getContractLog(String contractId, String inTxnCD) {
        DetachedCriteria criteria = DetachedCriteria.forClass(CpsBtContractLog.class);
        criteria.add(Restrictions.eq("contractId", contractId));
        criteria.add(Restrictions.eq("lastUpdTrancode", inTxnCD));
        List<CpsBtContractLog> list = this.findByCriteria(criteria);
        if (list.size() > 0) {
            return list.get(0);
        } else {
            return null;
        }
    }

}
